//
//  ModeSelect.m
//  Memory Mania
//
//  Created by Sanket Karkhanis on 2/20/12.
//  Copyright 2012 University of Southern California. All rights reserved.
//

#import "ModeSelect.h"
#import "GridSizeSelect.h"
#import "HelloWorldLayer.h"
#import "PlayerSelect.h"

@implementation ModeSelect
@synthesize mode;


+(id) scene
{
    CCScene *scene = [CCScene node];
    ModeSelect *layer = [ModeSelect node];
    [scene addChild:layer];
    return  scene;
    
}

- (id)init
{
    self = [super init];
    if (self) {
        mode = 0;
        CCMenuItem *classic = [CCMenuItemFont itemFromString:@"Classic" target:self selector:@selector(onClassic:)];
        CCMenuItem *advance = [CCMenuItemFont itemFromString:@"Advance" target:self selector:@selector(onAdvance:)];
        CCMenuItem *back = [CCMenuItemFont itemFromString:@"Back" target:self selector:@selector(onBack:)];      
        
        classic.scale = 3.0f;
        advance.scale = 3.0f;
        back.scale = 2.0f;
        
        //background
        CCSprite *MSBg = [CCSprite spriteWithFile:@"steve-took-it-water-drops.jpg"];		
        MSBg.anchorPoint = ccp(0.5,0.5);
        MSBg.position = ccp(512,384);
		//PSBg.opacity = 70;        
        [self addChild:MSBg z:0 tag:1];         
   
        CCMenu *menu = [CCMenu menuWithItems:classic, advance, back, nil];
        
        [menu alignItemsVerticallyWithPadding:50.0f];
        [self addChild:menu];
        
                
    }
    
    return self;
}

-(void) onClassic: (id) sender
{
  
    mode= 1;
      NSLog(@"Current mode %i",mode);
    [[CCDirector sharedDirector] replaceScene:[CCTransitionSplitRows transitionWithDuration:1.0 scene:[GridSizeSelect node]]]; 
}

-(void) onAdvance: (id) sender
{
    NSLog(@"To play screen4");
    mode = 2;
    [[CCDirector sharedDirector] replaceScene:[CCTransitionSplitRows transitionWithDuration:1.0 scene:[GridSizeSelect node]]]; 
}

-(void) onBack: (id) sender
{
    NSLog(@"To play screen4");
    [[CCDirector sharedDirector] replaceScene:[CCTransitionFlipY transitionWithDuration:1.0 scene:[PlayerSelect node]]]; 
}@end
